{% extends 'drops/drops_base.html' %}
{% import 'bootstrap/wtf.html' as wtf %}
{% import "drops/_macros.html" as macros %}
{% block title %} drops-管理 {% endblock%}
{% block page_content %}
<div class="page-header">
    <h1>drops编辑</h1>
</div>
<form role="form" method='POST'>
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<div class="form-group w90">
   <label for="name"></label>
   <input type="text" class="vertical-align: middle" name="opt" placeholder="请输入查询关键字">
   <button type="submit" class="btn btn-danger">提交</button>
</div>
</form>
<hr>
<div class="table-responsive w90">

    <table id="main" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <td>文章ID</td>
                <td>标题</td>
                <td>更新时间</td>
                <td>类別</td>
                <td>管理</td>
            </tr>
            </thread>
            <tbody>
            {% if not posts %}
                <tr>
                    <td><a href="{{ url_for('drops.newdrops')}}" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span>沒有文章，点此新建？</a></td>
                </tr>
            {% else %}
                {% for i in posts %}
                <tr>
                    <td>{{i.id}}</td>
                    <td>{{i.drop_title}}</td>
                    <td>{{moment(i.drop_modified_time).format('YYYY年M月D日, H:mm:ss')}}</td>
                    <td>{{i.cate.category_name}}</td>
                    <td>
                        <button onclick="del({{i.id}})" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span>刪除</button>
                        <a href="{{ url_for('drops.newdrops')}}" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span>新建</a>
                        <a href="{{ url_for('drops.editdrops',id=i.id)}}" class="btn btn-primary"><span class="glyphicon glyphicon-edit"></span>编辑</a>
                        <a href="{{ url_for('drops.downdrops',postid=i.id)}}" type="button" class="btn btn-warning"><span class="glyphicon glyphicon-download"></span>下载</a></button>
		            </td>
		        </tr>
                {% endfor %}
            {% endif%}

            </tbody>
    </table>
</div>

{% if pagination %}
<div class="pagination">
    {{ macros.pagination_widget(pagination, '.readdrops') }}
</div>
{% endif %}
<script>

function del(id){
var msg="確定要刪除吗？\n注意：刪除后无法恢复！"
if (confirm(msg)){
	$.get('/srcpm/drops/deldrop/'+id,function(){alert("目标项目已成功刪除！");location.reload();})
	}
}

</script>
{% endblock %}
